function cycle(dir, arr, cur) {
    var idx = arr.indexOf(cur);
    return idx>-1?arr[(idx + dir + arr.length) % arr.length]:null
}